﻿<local:BaseWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MicroBlogClient"  ResizeMode="CanResizeWithGrip"
        xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
         xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="MicroBlogClient.MainWindow"
        Icon="/Resources/logo.ico" WindowStartupLocation="CenterScreen" Title="{StaticResource AppTitle}" Opacity="{Binding CurrentUser.UserSettings.MainWindowOpacity}"
         WindowStyle="None" AllowsTransparency="True" Background="{x:Null}"  Closing="mainWindow_Closing" FontFamily="Microsoft YaHei,Sim Sun"
    MinWidth="307" MinHeight="500"
    x:Name="mainWindow" Height="650" Width="307">
    <local:BaseWindow.Resources> 
        <Storyboard x:Key="StoryBoardPopupAnimation">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="popupMessageContainer">
            	<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                <SplineDoubleKeyFrame KeyTime="0:0:1.5" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="popupMessageContainer">
                <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Visible}"/>
                <DiscreteObjectKeyFrame KeyTime="0:0:1.5" Value="{x:Static Visibility.Collapsed}"/>
            </ObjectAnimationUsingKeyFrames>
        </Storyboard>
    </local:BaseWindow.Resources>
    <Border Style="{DynamicResource MainWindowBorder}" x:Name="MainBorder">
        <Border CornerRadius="5" BorderThickness="1">
            <!--main content starts from here-->
            <Grid>
                  <local:UCLogin x:Name="ucLogin" OnLoginFinished="ucLogin_OnLoginFinished" 
                               Margin="0,40,0,0" Panel.ZIndex="3"
                               />  
                <local:UCSettings x:Name="ucSettings" Visibility="Collapsed"
                                  OnSettingsCancel="ucSettings_OnSettingsCancel" 
                                  OnMainWindowOpacityChanged="ucSettings_OnMainWindowOpacityChanged"
                                  OnSettingsSaved="ucSettings_OnSettingsSaved"
                                  Panel.ZIndex="1" 
                                  HorizontalAlignment="Center" 
                                  VerticalAlignment="Center" /> 
                <!--popup layer-->
                <Border Style="{DynamicResource PopupMessageBorderStyle}" x:Name="popupMessageContainer" Panel.ZIndex="2" >
                    <DockPanel  Margin="10">
                        <ContentControl  x:Name="popupImageIcon" DockPanel.Dock="Left" VerticalAlignment="Center" />
                        <TextBlock x:Name="popupTextBlockText" Style="{DynamicResource PopupMessageTextBlockStyle}" />
                    </DockPanel>
                </Border>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="80"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Canvas Height="15" Grid.Row="0" VerticalAlignment="Top" Opacity="0.3" Background="{DynamicResource WindowTitleBackground}" />
                    <Canvas Height="32" Grid.Row="0" Background="{DynamicResource TitleBarLeftCornerHighlight}"/>
                    <!--Title Bar started-->
                    <Border BorderBrush="{DynamicResource WindowTitleBarInnerBorder}" CornerRadius="5,5,0,0" Margin="0" BorderThickness="1,1,0,0">
                        <ContentControl PreviewMouseLeftButtonDown="Window_PreviewMouseDown" PreviewMouseDoubleClick="ContentControl_PreviewMouseDoubleClick">
                            <Canvas Height="32" Grid.Row="0" Margin="5,3,5,0">
                                <Image Height="16" Width="16" Source="/Resources/logo16.png"/>
                                <TextBlock Text="{StaticResource AppTitle}" Canvas.Left="22" Style="{DynamicResource AppTitleStyle}"/>
                                <StackPanel Orientation="Horizontal" Canvas.Right="0">
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="设置"  Click="btnTitleBarSettings_Click">
                                        <controls:ImageEx Source="{DynamicResource SettingsButton}" Stretch="Uniform" Width="10" Height="10"/>
                                    </Button>
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="最小化" Click="btnTitleBarMin_Click">
                                        <controls:ImageEx Source="{DynamicResource MinButton}"    Width="14" Height="12" Stretch="Uniform"/>
                                    </Button>
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="最大化"  Click="btnTitleBarMaximze_Click">
                                        <controls:ImageEx Source="{DynamicResource MaxButton}"  Width="14" Height="12" Stretch="Uniform"/>
                                    </Button>
                                    <Button Style="{DynamicResource WindowTitleBarButtonStyle}" ToolTip="关闭"  Click="btnTitleBarClose_Click">
                                        <controls:ImageEx Source="{DynamicResource CloseButton}" Width="14" Height="12"  Stretch="Uniform"/>
                                    </Button>
                                </StackPanel>
                            </Canvas>
                        </ContentControl>
                    </Border>
                    <!--Title Bar End-->
                    <!--Main Content Started-->
                    <!--My Information-->
                    <Grid Grid.Row="1" Margin="5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="65"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0" Style="{StaticResource HeadPictureBorderStyle}"> 
                            <Image Stretch="Fill"  Source="{Binding Me.ProfileImageUrl,Converter={StaticResource ImageConverter}}" 
                                    VerticalAlignment="Center"
                                    HorizontalAlignment="Center" 
                                   Height="48" Width="48"/>
                        </Border> 
                        <Grid VerticalAlignment="Center"  HorizontalAlignment="Left" Grid.Column="1" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="15"/>
                                <RowDefinition Height="40"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.Resources>
                                <Style TargetType="TextBlock">
                                    <Setter Property="Foreground" Value="{DynamicResource AppTitleColorBrush}"/>
                                    <Setter Property="HorizontalAlignment" Value="Center"/>
                                </Style>
                            </Grid.Resources>

                            <TextBlock Text="{Binding Me.ScreenName,FallbackValue=韩现龙}"
                                   Grid.Row="0"
                                   Grid.Column="0"
                                   Grid.ColumnSpan="3" HorizontalAlignment="Left"
                                       Margin="20,0,0,0" Style="{DynamicResource AppTitleStyle}"  />
                            <Border  Style="{DynamicResource MyInformationStyle}"
                                     Grid.Row="1"
                                     Grid.Column="0" IsHitTestVisible="True"
                                     PreviewMouseLeftButtonDown="OpenMyFollowingOnWebPage_Click">
                                <StackPanel>
                                    <TextBlock Foreground="{DynamicResource AppTitleColorBrush}" Text="{Binding Me.FriendsCount,FallbackValue=50000}"/>
                                    <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="关注"/>
                                </StackPanel>
                            </Border>
                            <Border Style="{DynamicResource MyInformationStyle}" Grid.Row="1"  PreviewMouseLeftButtonDown="OpenMyFollowersOnWebPage_Click" Grid.Column="1">
                                <StackPanel>
                                    <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="{Binding Me.FollowersCount,FallbackValue=50000}"/>
                                    <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="粉丝" Canvas.Bottom="0"/>
                                </StackPanel>
                            </Border>
                            <Canvas Grid.Column="1" Margin="20,0,0,0" Cursor="Hand" Grid.Row="1"  PreviewMouseLeftButtonDown="OpenMyFollowersOnWebPage_Click"   Visibility="{Binding NewFollowersCount, ConverterParameter=0, Converter={StaticResource IntegerGreaterThanToVisibilityConverter}, ElementName=mainWindow}">
                                <Ellipse Cursor="Hand" Canvas.Left="15" Canvas.Top="1" Stroke="White" StrokeThickness="1" Fill="Red" Height="18" Width="25"/>
                                <TextBlock Canvas.Left="20" Canvas.Top="2" Foreground="White" Text="{Binding NewFollowersCount, ElementName=mainWindow, StringFormat=+\{0\}}" FontSize="9" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Canvas>
                            <Border Style="{DynamicResource MyInformationStyle}" Grid.Row="1"  Grid.Column="2" PreviewMouseLeftButtonDown="OpenMyStatusOnWebPage_Click">
                                <StackPanel>
                                    <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="{Binding Me.StatusesCount,FallbackValue=50000}"/>
                                    <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="微博"/>
                                </StackPanel>
                            </Border>
                        </Grid>
                    </Grid>

                    <!--Main Content-->
                    <Border CornerRadius="5" Grid.Row="2">
                        <TabControl Style="{DynamicResource mainTabControlStyle}" x:Name="tabMainControl">
                            <TabItem Background="{DynamicResource MainMenuHoverBackgroundBrush}"  BorderThickness="0,0,1,0" x:Name="tabItemStatus" Style="{DynamicResource MainTabItemStyle}">
                                <TabItem.Header>
                                    <Canvas Background="{DynamicResource MainMenuHome}" PreviewMouseLeftButtonDown="FlushFriendsStatusPool"  Height="27" Width="24" ToolTip="我的关注">
                                        <Canvas Cursor="Hand" Visibility="{Binding NewFriendsStatusCount, ConverterParameter=0, Converter={StaticResource IntegerGreaterThanToVisibilityConverter}, ElementName=mainWindow}">
                                            <Ellipse Cursor="Hand" Canvas.Left="15" Canvas.Top="1" Stroke="White" StrokeThickness="1" Fill="Red" Height="18" Width="25"/>
                                            <TextBlock  Canvas.Left="20" Canvas.Top="2" Foreground="White" Text="{Binding NewFriendsStatusCount, ElementName=mainWindow, StringFormat=+\{0\}}" FontSize="9" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Canvas>
                                    </Canvas>
                                </TabItem.Header>
                                <Frame Source="Pages/FriendsStatus.xaml" x:Name="frmFriendsStatus"/>
                            </TabItem>
                            <TabItem BorderThickness="0,0,1,0"  Style="{DynamicResource MainTabItemStyle}" x:Name="tabItemMyComments">
                                <TabItem.Header>
                                    <Canvas Background="{DynamicResource MainMenuComments}" PreviewMouseLeftButtonDown="FlushMyCommentStatusPool"  Height="27" Width="24" ToolTip="我的评论">
                                        <Canvas Cursor="Hand" Visibility="{Binding NewCommentsCount, ConverterParameter=0, Converter={StaticResource IntegerGreaterThanToVisibilityConverter}, ElementName=mainWindow}">
                                            <Ellipse Cursor="Hand" Canvas.Left="15" Canvas.Top="1" Stroke="White" StrokeThickness="1" Fill="Red" Height="18" Width="25"/>
                                            <TextBlock Canvas.Left="20" Canvas.Top="2" Foreground="White" Text="{Binding NewCommentsCount, ElementName=mainWindow, StringFormat=+\{0\}}" FontSize="9" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Canvas>
                                    </Canvas>
                                </TabItem.Header>
                                <Frame Source="Pages/Comments.xaml" x:Name="frmComments"/>
                            </TabItem>
                            <TabItem   BorderThickness="0,0,1,0"  Style="{DynamicResource MainTabItemStyle}" x:Name="tabItemMetionedMe">
                                <TabItem.Header>
                                    <Canvas Background="{DynamicResource MainMenuMetionedMe}"  PreviewMouseLeftButtonDown="FlushMetionedMeStatusPool" Height="27" Width="24" ToolTip="@我的">
                                        <Canvas Cursor="Hand" Visibility="{Binding NewMetionedMeCount, ConverterParameter=0, Converter={StaticResource IntegerGreaterThanToVisibilityConverter}, ElementName=mainWindow}">
                                            <Ellipse Cursor="Hand" Canvas.Left="15" Canvas.Top="1" Stroke="White" StrokeThickness="1" Fill="Red" Height="18" Width="25"/>
                                            <TextBlock Canvas.Left="20" Canvas.Top="2" Foreground="White" Text="{Binding NewMetionedMeCount, ElementName=mainWindow, StringFormat=+\{0\}}" FontSize="9" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Canvas>
                                    </Canvas>
                                </TabItem.Header>
                                <Frame Source="Pages/MetionedMe.xaml" x:Name="frmMetionedMe"/>
                            </TabItem>
                            <TabItem  BorderThickness="0,0,1,0"  Style="{DynamicResource MainTabItemStyle}" x:Name="tabItemMyLetters" >
                                <TabItem.Header>
                                    <Canvas Background="{DynamicResource MainMenuLetter}" PreviewMouseLeftButtonDown="FlushMyLetterPool" Height="27" Width="24" ToolTip="我的私信">
                                        <Canvas Cursor="Hand"  Visibility="{Binding NewLetterCount, ConverterParameter=0, Converter={StaticResource IntegerGreaterThanToVisibilityConverter}, ElementName=mainWindow}">
                                            <Ellipse Cursor="Hand" Canvas.Left="15" Canvas.Top="1" Stroke="White" StrokeThickness="1" Fill="Red" Height="18" Width="25"/>
                                            <TextBlock Canvas.Left="20" Canvas.Top="2" Foreground="White" Text="{Binding NewLetterCount, ElementName=mainWindow, StringFormat=+\{0\}}" FontSize="9" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Canvas>
                                    </Canvas>
                                </TabItem.Header>
                                <Frame Source="Pages/Letters.xaml" x:Name="frmLetter"/>
                            </TabItem>
                            <TabItem Style="{DynamicResource MainTabItemStyle}" BorderThickness="0,0,1,0"  x:Name="tabItemUserPage">
                                <TabItem.Header>
                                    <Canvas Background="{DynamicResource MainMenuUser}" Height="27" Width="24" ToolTip="主页"/>
                                </TabItem.Header>
                                <Frame Source="Pages/UserPage.xaml" NavigationUIVisibility="Hidden" x:Name="frmUser"/>
                            </TabItem>
                            <TabItem  Style="{DynamicResource MainTabItemStyle}">
                                <TabItem.Header>
                                    <Canvas Background="{DynamicResource MainMenuSearch}" Height="27" Width="24" ToolTip="搜索"/>
                                </TabItem.Header>
                                <Frame Source="Pages/Search.xaml" x:Name="frmSearch"/>
                            </TabItem>
                           
                        <!--<TabItem Header="{DynamicResource MainMenuFavorite}" BorderThickness="0,0,1,0"   Style="{DynamicResource MainTabItemStyle}">
                            Group
                        </TabItem>-->
                        </TabControl>
                    </Border>
                    <!--Function-->
                    <StackPanel Grid.Row="2" VerticalAlignment="Bottom" Margin="0,0,0,35" HorizontalAlignment="Left">
                        <local:UCPublishStatus x:Name="ucPublisStatus" 
                                                OnPublishFailed="InvokeFailedEvent"
                                               OnPublishStart="InvokeStartingEvent"
                                                OnRequestingShowSuccessfulMessage="InvokeFinishedEvent"
                                               OnPublishFinished="ucPublisStatus_OnPublishFinished"
                                               />
                        <controls:ImageEx Source="{DynamicResource HorizontalSplitter}" Height="2" Stretch="Fill" />
                    </StackPanel>
                    <controls:PopupEx x:Name="popupUserInformation" Placement="Left"  Opacity="0.8" Height="180"  MouseLeave="popupUserInformation_MouseLeave" Width="280" AllowsTransparency="True"  Margin="0"  PopupAnimation="Fade">
                        <Border  Height="180"  Width="280"  Padding="5" CornerRadius="5" Style="{DynamicResource MainWindowBorder}" >
                            <Border.Effect>
                                <DropShadowEffect/>
                            </Border.Effect>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="20"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="48"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel Grid.Column="0" Grid.Row="0">
                                    <Border BorderBrush="#54a5d5"  HorizontalAlignment="Left" VerticalAlignment="Top" Height="48" Width="48" BorderThickness="1">
                                        <TextBlock ToolTip="点击查看TA的主页">
	                                        <Hyperlink x:Name="linkCurrentUserHeadPicture"  Click="linkOpenUserBlog_Click"  TextDecorations="None">
	                                            <Image Grid.Row="0"  Opacity="1" x:Name="currentUserHeadPicture" Grid.Column="0" Source="{Binding CurrentUser.ProfileImageUrl,Converter={StaticResource ImageConverter}}"/>
	                                        </Hyperlink>
                                        </TextBlock>
                                    </Border>
                                    <TextBlock x:Name="tbCurrentUserLocation" TextWrapping="Wrap" HorizontalAlignment="Center" Padding="5,0,0,0" Style="{DynamicResource AppTitleStyle}" Text="{Binding CurrentUser.Location,FallbackValue=北京－海淀}"/>
                                </StackPanel>
                                <Grid Grid.Column="1" Grid.Row="0" Margin="0,2,2,2" >
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="15"/>
                                        <RowDefinition Height="40"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.Resources>
                                        <Style TargetType="TextBlock">
                                            <Setter Property="Foreground" Value="{DynamicResource AppTitleColorBrush}"/>
                                            <Setter Property="HorizontalAlignment" Value="Center"/>
                                        </Style>
                                    </Grid.Resources>

                                    <TextBlock PreviewMouseDown="OpenUserPageOnWebPage_Click" Cursor="Hand"
                                       Grid.Row="0" Text="{Binding CurrentUser.ScreenName,FallbackValue=韩现龙}"
                                       Grid.Column="0"
                                       Grid.ColumnSpan="3" HorizontalAlignment="Left"
                                           Margin="20,0,0,0"  ToolTip="点击查看TA的主页"
                                        Style="{DynamicResource AppTitleStyle}"/>

                                    <Border  Style="{DynamicResource MyInformationStyle}"
                                     Grid.Row="1"
                                     Grid.Column="0" IsHitTestVisible="True"
                                     PreviewMouseLeftButtonDown="OpenUserFollowingOnWebPage_Click">
                                        <StackPanel>
                                            <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="{Binding CurrentUser.FriendsCount,FallbackValue=50000}"/>
                                            <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="关注"/>
                                        </StackPanel>
                                    </Border>
                                    <Border Style="{DynamicResource MyInformationStyle}" Grid.Row="1"  PreviewMouseLeftButtonDown="OpenUserFollowersOnWebPage_Click" Grid.Column="1">
                                        <StackPanel>
                                            <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="{Binding CurrentUser.FollowersCount,FallbackValue=50000}"/>
                                            <TextBlock Foreground="{DynamicResource AppTitleColorBrush}"  Text="粉丝" Canvas.Bottom="0"/>
                                        </StackPanel>
                                    </Border>
                                    <Border Style="{DynamicResource MyInformationStyle}" Grid.Row="1"  Grid.Column="2"
                                            PreviewMouseLeftButtonDown="OpenUserPageOnWebPage_Click">
                                        <StackPanel>
                                            <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="{Binding CurrentUser.StatusesCount,FallbackValue=50000}"/>
                                            <TextBlock  Foreground="{DynamicResource AppTitleColorBrush}"  Text="微博"/>
                                        </StackPanel>
                                    </Border>
                                </Grid>
                                <Border CornerRadius="5" Grid.Row="2" Grid.ColumnSpan="2" Opacity="0.8">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFC8D4DB" Offset="1"/>
                                            <GradientStop Color="White"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                <StackPanel>
                                    <TextBlock Padding="5,0,0,0">
                                        <TextBlock Visibility="{Binding CurrentUser.Following,Converter={StaticResource ContrastBooleanToVisibilityConverter}}">
                                            <Hyperlink x:Name="linkCreateFriendshipWithCurrentUser" Click="linkCreateFriendshipWithCurrentUser_Click">关注TA</Hyperlink>
                                              <TextBlock Margin="5,0,0,0"/>
                                            <Hyperlink x:Name="linkAskForFollowing" Click="linkAskForFollowedCurrentUser_Click">互粉请求</Hyperlink>
                                        </TextBlock>
                                        <TextBlock Visibility="{Binding CurrentUser.Following,Converter={StaticResource BooleanToVisibilityConverter}}">
                                            <Hyperlink x:Name="linkRemoveFriend" Click="linkRemoveFriendCurrentUser_Click">取消关注</Hyperlink>
                                             <TextBlock Margin="5,0,0,0"/>
                                            <Hyperlink x:Name="linkSendLetterToCurrentUser"  Click="linkSendLetterToCurrentUser_Click">发私信</Hyperlink>
                                             <TextBlock Margin="5,0,0,0"/>
                                            <Hyperlink x:Name="linkChatWithCurrentUser"  Click="linkChatWithCurrentUser_Click">聊天</Hyperlink>
                                        </TextBlock>
                                        <TextBlock  Margin="5,0,0,0">
                                            <Hyperlink x:Name="linkSpeakToSomebody" Click="linkSpeakToSomebody_Click">@Ta</Hyperlink>
                                        </TextBlock>
                                        <TextBlock  Margin="5,0,0,0">
                                            <Hyperlink x:Name="linkOpenUserPageInBrowser" Click="linkOpenUserInBrowser">网页打开</Hyperlink>
                                        </TextBlock>
                                    </TextBlock>
                                </StackPanel>
                                </Border>
                            </Grid>
                        </Border>
                    </controls:PopupEx>
                    <!--Main Content End-->
                </Grid>
            </Grid>
        </Border>
    </Border>
</local:BaseWindow>
